class CoursesController < ApplicationController
  
  def index
    @posts = Post.all.find_all { |po| po.course =~ /ACCT/ }
  end
  
  def newpost
    Post.create(:name => params[:name], :course => params[:course], :comment => params[:comment]);
  end
  
  def reload
    @posts = Post.all.find_all { |po| po.course =~ /#{params[:selected]}/ }
    @posts.sort!{ |a,b| b.created_at <=> a.created_at }
    
    respond_to do |format|
      format.html #{redirect_to posts_url(:selected => params[:selected]) }
      format.json { render :json => @posts }
    end
  end
  
end
